package com.iflytek.day28._02_properties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

public class _03_PropertiesDemo {
  public static void main(String[] args) throws IOException {
    // 把集合中的数据保存到文件
    // myStore();
    // 把文件中的数据加载到集合
    myLoad();

  }

  private static void myLoad() throws IOException {
    Properties prop = new Properties();

    // void load(Reader reader)：
    FileReader fr = new FileReader("src\\com\\iflytek\\day28\\_02_properties\\fw.txt");
    prop.load(fr);
    fr.close();

    System.out.println(prop);
  }

  private static void myStore() throws IOException {
    Properties prop = new Properties();

    prop.setProperty("sias001", "佟丽娅");
    prop.setProperty("sias002", "赵丽颖");
    prop.setProperty("sias003", "刘诗诗");

    // void store(Writer writer, String comments)：
    FileWriter fw = new FileWriter("src\\com\\iflytek\\day28\\_02_properties\\fw.txt");
    prop.store(fw, null);
    fw.close();
  }
}
